package Dao;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;


public class DaoUtil {
	public static Connection getConnection() throws IOException,ClassNotFoundException,SQLException{
		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;user=sa;password=123;database=EmployeeTransferManager");
		
		return con;
	}
	
	public static void closeConnection(Connection con) throws SQLException{
		if(!con.isClosed())
			con.close();
	}
	
	public static Statement getStatement(Connection con) throws SQLException {
		return con.createStatement();
	}
	
	public static PreparedStatement getPreparedStatement(Connection con,
			String sql) throws SQLException {
		return con.prepareStatement(sql);
	}
}
